#pragma once

#include <bofcl_eclic.h>

// 根据level、priority域的位数和其数值返回clicintctl（level_priority）域的值
static inline u32_s
eclic_set_level_priority_by_bit_amount(u32_s level_bit_amount,
				       u32_s level, u32_s priority,
				       u32_s level_priority_bit_amount) {
	u8_s all_1 = -1;
	u32_s low_bits = all_1 >> level_priority_bit_amount;

	u32_s low_bit_amount = 8 - level_priority_bit_amount;
	u32_s priority_bits = priority << low_bit_amount;

	u32_s add_low_priority_bit_amount = 8 - level_bit_amount;
	u32_s level_bits = level << add_low_priority_bit_amount;

	return level_bits | priority_bits | low_bits;
}
